/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.user.core;

import org.user.exception.InvalidUserException;

/**
 *
 * @author v-lascha
 */
public class UserService {

    private UserDAO userdao;

    /**
     * Save the UserBean in the db
     * @param user
     */
    public void saveUser(UserBean user) {
        getUserdao().saveUser(user);
    }

    /**
     * Get the appropriate UserBean from the db with respective to the given
     * username and password
     * @param uname
     *          The user name for user
     * @param password
     *          The password for user
     * @return
     *          The valid UserBean if credentials are correct
     * @throws org.user.exception.InvalidUserException
     *          Throw when given credentials are incorrect
     */
    public UserBean getUser(String uname, String password) throws InvalidUserException {
        return getUserdao().getUser(uname, password);
    }

    /**
     * Checks for the exsisting user accounts for a given user name
     * @param uname
     *          The user name for user
     * @return
     *          True is the username is already used otherwise false
     */
    public boolean isUserExists(String uname) {
        return getUserdao().isUserExists(uname);
    }

    /**
     * @return Returns the userdao.
     */
    public UserDAO getUserdao() {
        return userdao;
    }

    /**
     * @param userdao The userdao to set.
     */
    public void setUserdao(UserDAO userdao) {
        this.userdao = userdao;
    }
}
